#pragma once

#include <gofcl_usbfs_r.h>

typedef struct {
	u32_s CSRST : 1;
	u32_s HCSRST : 1;
	u32_s HFCRST : 1;
	u32_s : 1;
	u32_s RXFF : 1;
	u32_s TXFF : 1;
	u32_s TXFNUM : 5;
	u32_s : 21;
} usbfs_grstctl_s;

_Static_assert(sizeof(usbfs_grstctl_s) == 4,
	       "Struct usbfs_grstctl_s defined error!");

static inline void usbfs_wreg_grstctl_s(usbfs_grstctl_s rstctl) {
	union {
		usbfs_grstctl_s g;
		u32_s u;
	} gu = {
		.g = rstctl,
	};
	usbfs_wreg(USBFS_GRSTCTL_R, gu.u);
}

static inline usbfs_grstctl_s usbfs_rreg_grstctl_s(void) {
	union {
		usbfs_grstctl_s g;
		u32_s u;
	} gu = {
		.u = usbfs_rreg(USBFS_GRSTCTL_R),
	};
	return gu.g;
}
